package com.apes.fn.scm.retailOrder.service.retailProcess.process;

import com.apes.fn.scm.retailOrder.model.RetailOrder;
import com.apes.fn.scm.retailOrder.service.retailProcess.CommonRetailDataProcess;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 储值订单
 * @author wuq
 * @create 2021-05-21 16:58
 */
@Service
public class StoredValueProcess extends CommonRetailDataProcess {

    @Override
    public void beforeSave(RetailOrder retailOrder) {
        beforeProcess(retailOrder, this::updateScene);
    }

    private void updateScene(RetailOrder retailOrder){
        if (retailOrder.getAmtTotal() < 0 ) {
            retailOrder.setScene(null);
            retailOrder.setPostDate(new Date());
        }
    }

    @Override
    public void afterSave(RetailOrder retailOrder) {

    }

    @Override
    public boolean support(String orderType) {
        return "storedValue".equals(orderType);
    }
}
